package com.example.a429;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class RegisterActivity extends AppCompatActivity {

    private EditText etUsername, etPhoneNumber, etVerificationCode, etPassword, etConfirmPassword;
    private Button btnGetVerificationCode, btnRegister;
    private TextView tvAgreement, tvLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        etUsername = findViewById(R.id.et_username);
        etPhoneNumber = findViewById(R.id.et_phone_number);
        etVerificationCode = findViewById(R.id.et_verification_code);
        etPassword = findViewById(R.id.et_password);
        etConfirmPassword = findViewById(R.id.et_confirm_password);
        btnGetVerificationCode = findViewById(R.id.btn_get_verification_code);
        btnRegister = findViewById(R.id.btn_register);
        tvAgreement = findViewById(R.id.tv_agreement);
        tvLogin = findViewById(R.id.tv_login);

        btnGetVerificationCode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String phoneNumber = etPhoneNumber.getText().toString();
                // 这里添加获取验证码逻辑
                Toast.makeText(RegisterActivity.this, "获取验证码：" + phoneNumber, Toast.LENGTH_SHORT).show();
            }
        });

        btnRegister.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String username = etUsername.getText().toString();
                String phoneNumber = etPhoneNumber.getText().toString();
                String verificationCode = etVerificationCode.getText().toString();
                String password = etPassword.getText().toString();
                String confirmPassword = etConfirmPassword.getText().toString();
                // 这里添加注册逻辑
                Toast.makeText(RegisterActivity.this, "尝试注册：" + username, Toast.LENGTH_SHORT).show();
            }
        });

        btnRegister.setOnClickListener(v -> {
            // 创建一个 Intent 对象，用于从 LoginActivity 跳转到 RegisterActivity
            Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
            // 启动 RegisterActivity
            startActivity(intent);
        });
    }
}